package com.myteam.mystory.service;

import java.util.ArrayList;

import com.myteam.mystory.DAO.ChapterDAO;
import com.myteam.mystory.DAO.CreateDatabase;
import com.myteam.mystory.DAO.ParamDAO;
import com.myteam.mystory.DAO.ParamScheme;
import com.myteam.mystory.entity.ChapterEntity;
import com.myteam.mystory.entity.ParamEntity;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class ParamService {
	private final Context context;

	public ParamService(Context context) {
		super();
		this.context = context;
	}
	
	public long insert_param(ParamEntity paramEntity){
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		ParamDAO paramDAO = new ParamDAO(db);
		long result = paramDAO.insert_chapter(paramEntity);
		db.close();
		createDb.close();
		return result;
	}
	
	public ArrayList<ParamEntity> getAllParam() {
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		ParamDAO paramDAO = new ParamDAO(db);
		ArrayList<ParamEntity> list_param = new ArrayList<ParamEntity>();
		list_param = paramDAO.getAllParam();
		db.close();
		createDb.close();
		return list_param;
	}
	
	public long deleteTableParam(){
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		ParamDAO paramDAO = new ParamDAO(db);
		long result = paramDAO.deleteTableParam();
		db.close();
		createDb.close();
		return result;
	}
}
